package com.legutech.gsyvideoplayer.gsy_video_player;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;

import com.shuyu.gsyvideoplayer.utils.Debuger;
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer;

import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugin.platform.PlatformView;

public class GSYVideoPlayerView implements PlatformView {

    private RealVideo video;

    public GSYVideoPlayerView(Context context, String dataSource, String tag, String title, BinaryMessenger messenger) {
        RealVideo player = new RealVideo(context);
        this.video = player;
        video.setRotateViewAuto(true);// 是否开启制动旋转
        video.setLockLand(true);// false 全屏默认横屏
        video.setShowFullAnimation(true);
        video.setPlayTag(tag);
        video.setAutoFullWithSize(true);
        video.setReleaseWhenLossAudio(false);
        video.setIsTouchWiget(false);

        video.getBackButton().setVisibility(View.GONE);
//        video.getFullscreenButton().setVisibility(View.GONE);
        video.setIsTouchWiget(false);
        video.setUpLazy(dataSource, false, null, null, title);
        video.setNeedMute();
        video.postDelayed(() -> {
            video.startPlayLogic();
            video.setProgressState(false);
        }, 200);

    }

    @Override
    public View getView() {
        return this.video;
    }

    @Override
    public void dispose() {
        video.releaseVideos();
        // video.dispose();
    }

}
